package com.gtt.pattern.structural.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * Composite
 * 
 * @author 高甜甜(gao12581@sina.com)
 * @date 2011-3-31
 * 
 */
public class Composite extends Component {

	private List<Component> components = new ArrayList<Component>();

	public Composite(String name) {
		super(name);
	}

	@Override
	public void add(Component c) {
		components.add(c);
	}

	@Override
	public void dumpContents() {
		System.out.println("Node: " + this.name);

		for (Component c : components) {
			c.dumpContents();
		}
	}
}
